﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QLKS
{
    public partial class frxembaocao : Form
    {
        private DataTable _doanhThu;

        internal DataTable DoanhThu
        {
            get { return _doanhThu; }
            set { _doanhThu = value; }
        }
        public frxembaocao()
        {
            InitializeComponent();
        }

        private void btnthoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frxembaocao_Load(object sender, EventArgs e)
        {
            try
            {
                dgvThongKe.DataSource = DoanhThu;
            }
            catch (System.Exception )
            {
            	
            }
        }

        private void btnxemdt_Click(object sender, EventArgs e)
        {
            try
            {
                int Nam = int.Parse(txtNam.Text);
                if (Nam < 1000)
                {
                    MessageBox.Show("Ban nhap sai nam. Phai nhap 1999 hoac lon hon.");
                }
                else
                {
                    long TongDoanhThu = 0;
                    if (txtNam.Text != null && cbbDoanhThuThang.Text == "")
                    {
                        DoanhThu = BUS.XuLyBaoCao.TimBaoCaoNam(Nam);
                        foreach (DataRow dr in DoanhThu.Rows)
                        {
                            TongDoanhThu += long.Parse(dr["DoanhThuNgay"].ToString());
                        }
                    }
                    else if (txtNam.Text != null && cbbDoanhThuThang.Text != "")
                    {
                        int Thang = int.Parse(cbbDoanhThuThang.Text);
                        DoanhThu = BUS.XuLyBaoCao.TimBaoCaoThang(Thang, Nam);
                        foreach (DataRow dr in DoanhThu.Rows)
                        {
                            TongDoanhThu += long.Parse(dr["DoanhThuNgay"].ToString());
                        }
                    }
                    lblTongDoanhThu.Text = TongDoanhThu.ToString();

                    frxembaocao_Load(sender, e);
                }
            }
            catch (System.Exception )
            {
                MessageBox.Show("Ban phai nhap nam la so nguyen");
            }
        }
       
    }
}
